import {request} from "@/network/request";

// 样例,会了就删了
export function getMessage(goods){
  return requestForMy({
    method: "POST",// 发送方法 GET POST DELETE PUT
    url: "/home/data",// url地址后缀完整的在外部
    params:{
      goodsId: goods.goodsId,
      goodsTitle: goods.goodsTitle,
      goodsInfo: goods.goodsInfo,
      price: Number.parseFloat(goods.price),
      goodsImg: goods.goodsImg,
      goodsNum: goods.goodsNum,
    },
    headers:{ // 头文件封装
      Authorization: sessionStorage.getItem("userToken"),
      // 格式设置
      'Content-Type':'application/json'
    }
  })
}
//查看众筹列表
export function getCF(){
  return request({
    baseURL:"/crowd",
    method: "GET",// 发送方法 GET POST DELETE PUT
    url: "/crowdfunding/crowdFunding",// url地址后缀完整的在外部
    headers:{ // 头文件封装
      // 格式设置
      'Content-Type':'application/json'
    }
  })
}

//查看梦想列表
export function getDream(){
  return request({
    baseURL:"/crowd",
    method: "GET",// 发送方法 GET POST DELETE PUT
    url: "/crowdfunding/dreamCrowdfunding",// url地址后缀完整的在外部
    headers:{ // 头文件封装
      // 格式设置
      'Content-Type':'application/json'
    }
  })
}


//按id查询一条信息(众筹)
export function getCfOne(cfId){
  return request({
    baseURL:"/crowd",
    method: "GET",// 发送方法 GET POST DELETE PUT
    url: "/crowdfunding/crowdFunding/crowdFundingOne",// url地址后缀完整的在外部
    params:{
      cfId:cfId
    },
    headers:{ // 头文件封装
      Authorization: sessionStorage.getItem("userToken"),
      // 格式设置
      'Content-Type':'application/json'
    }
  })
}
//按id查询一条信息(梦想)
export function getdreamOne(cfId){
  return request({
    baseURL:"/crowd",
    method: "GET",// 发送方法 GET POST DELETE PUT
    url: "/crowdfunding/dreamCrowdfunding/crowdFundingOne",// url地址后缀完整的在外部
    params:{
      cfId:cfId
    },
    headers:{ // 头文件封装
      // 格式设置
      'Content-Type':'application/json'
    }
  })
}
//查看用户昵称
export function getUserName(userId){
  return request({
    timeout:5000,
    baseURL:"/api",
    method: "POST",// 发送方法 GET POST DELETE PUT
    url: "/sys/test/user/getnickname",// url地址后缀完整的在外部
    params:{
      name:userId
    },
    headers:{ // 头文件封装
      Authorization: sessionStorage.getItem("userToken"),
      // 格式设置
      'Content-Type':'multipart/form-data'
    }
  })
}
//查看用户头像
export function getUserurl(userId){
  return request({
    timeout:5000,
    baseURL:"/api",
    method: "POST",// 发送方法 GET POST DELETE PUT
    url: "/sys/user/lr/geturl",// url地址后缀完整的在外部
    params:{
      username:userId
    },
    headers:{ // 头文件封装
      Authorization: sessionStorage.getItem("userToken"),
      // 格式设置
      'Content-Type':'multipart/form-data'
    }
  })
}

//众筹发布表单上传
export function uploadCF(formData){
  return request({
    timeout:10000,
    baseURL:"/crowd",
    method: "POST",// 发送方法 GET POST DELETE PUT
    url: "/crowdfunding/crowdFunding/addIncludeImage",// url地址后缀完整的在外部
    data:formData,
    headers:{ // 头文件封装
      // 格式设置
      'token':sessionStorage.getItem('userToken'),
      'Content-Type':'multipart/form-data',
    }
  })
}
//梦想发布表单上传
export function uploadDream(formData){
  return request({
    timeout:10000,
    baseURL:"/crowd",
    method: "POST",// 发送方法 GET POST DELETE PUT
    url: "/crowdfunding/dreamCrowdfunding/addIncludeImage",// url地址后缀完整的在外部
    data:formData,
    headers:{ // 头文件封装
      // 格式设置
      'token':sessionStorage.getItem('userToken'),
      'Content-Type':'multipart/form-data',
    }
  })
}

//根据token查看该用户发布信息(众筹)
export function getUserRecord(){
  return request({
    baseURL:"/crowd",
    method: "GET",// 发送方法 GET POST DELETE PUT
    url: "/crowdfunding/crowdFunding/getCrowdFundingListByuserName",// url地址后缀完整的在外部
    headers:{ // 头文件封装
      Authorization: sessionStorage.getItem("userToken"),
      // 格式设置
      'Content-Type':'application/json',
      'token':sessionStorage.getItem('userToken')
    }
  })
}
//根据token查看该用户发布信息(梦想)
export function getUserRecord2(){
  return request({
    baseURL:"/crowd",
    method: "GET",// 发送方法 GET POST DELETE PUT
    url: "/crowdfunding/dreamCrowdfunding/getCrowdFundingListByuserName",// url地址后缀完整的在外部
    headers:{ // 头文件封装
      // 格式设置
      'Content-Type':'application/json',
      'token':sessionStorage.getItem('userToken')
    }
  })
}

//根据活动id查看所有图片
export function getListImages(activityId){
  return request({
    baseURL:"/crowd",
    method: "GET",// 发送方法 GET POST DELETE PUT
    url: "/crowdfunding/crowdfundingImage/getListByCfId",// url地址后缀完整的在外部
    params:{
      cfId:activityId
    },
    headers:{ // 头文件封装
      // 格式设置
      'Content-Type':'application/json'
    }
  })
}

//添加支付信息（支付）
export function payCF(fromData){
  return request({
    baseURL:"/crowd",
    method: "POST",// 发送方法 GET POST DELETE PUT
    url: "/crowdfunding/crowdFunding/recordCrowdFunding",// url地址后缀完整的在外部
    data:fromData,
    headers:{ // 头文件封装
      'token':sessionStorage.getItem('userToken'),
      'Content-Type':'multipart/form-data',
    }
  })
}

//添加支付信息(梦想)
export function payDream(fromData){
  return request({
    baseURL:"/crowd",
    method: "POST",// 发送方法 GET POST DELETE PUT
    url: "/crowdfunding/dreamCrowdfunding/recordCrowdFunding",// url地址后缀完整的在外部
    data:fromData,
    headers:{ // 头文件封装
      'token':sessionStorage.getItem('userToken'),
      'Content-Type':'multipart/form-data',
    }
  })
}
